package com.spvs.approval.support.callBack;

import com.spvs.approval.domain.ApprovalFromEntity;
import com.spvs.approval.support.ApprovalBusinessCall;
import com.spvs.approval.support.ApprovalBusinessContext;
import com.spvs.system.api.IEquipStockService;
import com.spvs.system.api.domain.LeaseCallBackAPI;
import com.spvs.system.api.domain.StockCallBackAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 入库审批回调
 */
@Component
public class RkBusinessCallBack implements ApprovalBusinessCall {

    @Autowired
    private IEquipStockService equipStockService;

    @Override
    public Boolean isCall(String type) {
        return ApprovalBusinessContext.TYPE_RK.equals(type);
    }

    @Override
    public void callback(ApprovalFromEntity from, Integer userSort,Long userId) {
        StockCallBackAPI stockCallBackAPI = new StockCallBackAPI();
        stockCallBackAPI.setId(from.getBusinessId());
        stockCallBackAPI.setPurchaseType(9L);
        Integer state = 0;
        switch (from.getStatus()){
            case 101:
                state = 1;
                break;
            case 201:
                state = 2;
                break;
            case 301:
                state = 3;
                break;
            case 302:
                state = 4;
                break;
        }
        stockCallBackAPI.setAuditStatus(state);
        equipStockService.callBack(stockCallBackAPI);
    }
}
